#!/bin/python3
# -*- coding: utf-8 -*-
import time

import pandas as pd
import numpy as np

# def get_page(str):
#     print('正在下载：',str)
#     time.sleep(2)
#     print('下载完成',str)
#
# name_list = ['xiaozi','aa','bb','cc']
#
# start_time = time.time()
#
# for i in range(len(name_list)):
#     get_page(name_list[i])
#
# end_tiem = time.time()
#
# print('%d second'%(end_tiem-start_time))



# 线程池
# 导入线程池模块对应的类
from multiprocessing.dummy import Pool
start_time = time.time()
def get_page(str):
    print('正在下载：',str)
    time.sleep(2)
    print('下载完成',str)

name_list = ['xiaozi','aa','bb','cc']

# 实例化一个线程池
pool = Pool(4)
# 将列表中的每一个列表元素传递给get_page进行处理,返回是一个列表
pool.map(get_page,name_list)

end_tiem = time.time()

print('%d second'%(end_tiem-start_time))